package com.alan.libapi.api.Impl;

import com.alan.libapi.api.ApiHttp;
import com.alan.libapi.api.ApiHttpRequest;
import com.alan.libapi.api.ApiResponse;
import com.alan.libapi.model.business.AppVersionInfo;
import com.alan.libapi.model.business.AreaInfo;
import com.alan.libapi.model.business.BankType;
import com.alan.libapi.model.business.BoundBankCard;
import com.alan.libapi.model.business.MySharedWifiProfit;
import com.alan.libapi.model.business.PaidRecord;
import com.alan.libapi.model.business.ResponsedDevice;
import com.alan.libapi.model.business.ResponsedToken;
import com.alan.libapi.model.business.SharedWifiInfo;
import com.alan.libapi.model.business.UserBoundDevice;
import com.alan.libapi.model.business.UserInfo;
import com.alan.libapi.model.business.UserPackageInfo;
import com.alan.libapi.model.business.UserPackageSituation;
import com.alan.libapi.model.business.UserSession;
import com.alan.libapi.model.business.UserToken;
import com.alan.libapi.model.business.WifiMonthProfit;
import com.alan.libapi.model.persistent.ErrorInfo;
import com.alan.libapi.model.persistent.ErrorSets;
import com.alan.libapi.model.persistent.HttpType;
import com.alan.libapi.model.persistent.ModifyPwdType;
import com.alan.libapi.model.persistent.Parameter;
import com.alan.libapi.model.persistent.UrlConstant;

import java.util.ArrayList;
import java.util.List;

/**
 * @className: ApiHttpImpl
 * @describtion: ApiHttpImpl
 * @author: AlanWang
 * @email: 850267876@qq.com
 * @time: 2016/4/17 18:29
 */
public class ApiHttpImpl implements ApiHttp {

    private static ApiHttpImpl _instance;
    private ApiHttpImpl() {
        super();
    }

    public static ApiHttpImpl getInstance() {
        if (_instance == null) {
            _instance = new ApiHttpImpl();
        }
        return _instance;
    }

    /**
     ******************************************************************************************************************
     *<-----------------------------------------以下为Get方式获取信息的业务接口--------------------------------------->
     *******************************************************************************************************************
     */
    @Override
    public ApiResponse<UserInfo> getUserInfo(UserSession userSession) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("userId", "" + userSession.getUserId()));
        paramList.add(new Parameter("session", userSession.getSession()));
        ApiHttpRequest<UserInfo> requestObject = new ApiHttpRequest<>(UrlConstant.GET_USER_INFO, paramList, UserInfo.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJson(HttpType.GET, requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<List<SharedWifiInfo>> getNearbySharedWifiList(UserSession userSession, int areaId, double longitude, double latitude) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("userId", "" + userSession.getUserId()));
        paramList.add(new Parameter("session", userSession.getSession()));
        paramList.add(new Parameter("areaId", "" + areaId));
        paramList.add(new Parameter("longitude", "" + longitude));
        paramList.add(new Parameter("latitude", "" + latitude));
        ApiHttpRequest<SharedWifiInfo> requestObject = new ApiHttpRequest<>(UrlConstant.GET_NEARBY_SHARED_WIFI_LIST, paramList, SharedWifiInfo.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJsonList(requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<UserBoundDevice> getUserBoundDevice(UserSession userSession) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("userId", "" + userSession.getUserId()));
        paramList.add(new Parameter("session", userSession.getSession()));
        ApiHttpRequest<UserBoundDevice> requestObject = new ApiHttpRequest<>(UrlConstant.GET_USER_BOUND_DEVICE, paramList, UserBoundDevice.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJson(HttpType.GET, requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<UserPackageSituation> getUserPackageSituation(UserSession userSession) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("userId", "" + userSession.getUserId()));
        paramList.add(new Parameter("session", userSession.getSession()));
        ApiHttpRequest<UserPackageSituation> requestObject = new ApiHttpRequest<>(UrlConstant.GET_USER_PACKAGE_SITUATION, paramList, UserPackageSituation.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJson(HttpType.GET, requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<List<SharedWifiInfo>> getMySharedWifiList(UserSession userSession) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("userId", "" + userSession.getUserId()));
        paramList.add(new Parameter("session", userSession.getSession()));
        ApiHttpRequest<SharedWifiInfo> requestObject = new ApiHttpRequest<>(UrlConstant.GET_MY_SHARED_WIFI_LIST, paramList, SharedWifiInfo.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJsonList(requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<SharedWifiInfo> getSharedWifiInfo(UserSession userSession, int wifiId) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("userId", "" + userSession.getUserId()));
        paramList.add(new Parameter("session", userSession.getSession()));
        paramList.add(new Parameter("wifiId", "" + wifiId));
        ApiHttpRequest<SharedWifiInfo> requestObject = new ApiHttpRequest<>(UrlConstant.GET_SHARE_WIFI_INFO, paramList, SharedWifiInfo.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJson(HttpType.GET, requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<List<MySharedWifiProfit>> getMyAllSharedWifiProfitList(UserSession userSession) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("userId", "" + userSession.getUserId()));
        paramList.add(new Parameter("session", userSession.getSession()));
        ApiHttpRequest<MySharedWifiProfit> requestObject = new ApiHttpRequest<>(UrlConstant.GET_MY_ALL_SHARED_WIFI_PROFIT_LIST, paramList, MySharedWifiProfit.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJsonList(requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<List<WifiMonthProfit>> getMySpecifyWifiProfitList(UserSession userSession, int wifiId) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("userId", "" + userSession.getUserId()));
        paramList.add(new Parameter("session", userSession.getSession()));
        paramList.add(new Parameter("wifiId", "" + wifiId));
        ApiHttpRequest<WifiMonthProfit> requestObject = new ApiHttpRequest<>(UrlConstant.GET_MY_SPECIFY_WIFI_PROFIT_LIST, paramList, WifiMonthProfit.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJsonList(requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<List<PaidRecord>> getMyPaidList(UserSession userSession) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("userId", "" + userSession.getUserId()));
        paramList.add(new Parameter("session", userSession.getSession()));
        ApiHttpRequest<PaidRecord> requestObject = new ApiHttpRequest<>(UrlConstant.GET_MY_PAID_LIST, paramList, PaidRecord.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJsonList(requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<List<UserPackageInfo>> getPackageInfoList(UserSession userSession) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("userId", "" + userSession.getUserId()));
        paramList.add(new Parameter("session", userSession.getSession()));
        ApiHttpRequest<UserPackageInfo> requestObject = new ApiHttpRequest<>(UrlConstant.GET_PACKAGE_INFO_LIST, paramList, UserPackageInfo.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJsonList(requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<List<BoundBankCard>> getMyBoundBankCardList(UserSession userSession) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("userId", "" + userSession.getUserId()));
        paramList.add(new Parameter("session", userSession.getSession()));
        ApiHttpRequest<BoundBankCard> requestObject = new ApiHttpRequest<>(UrlConstant.GET_MY_BOUND_BANKCARD_LIST, paramList, BoundBankCard.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJsonList(requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<AppVersionInfo> getAppVersion(int appPlatform) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("appPlatform", "" + appPlatform));
        ApiHttpRequest<AppVersionInfo> requestObject = new ApiHttpRequest<>(UrlConstant.GET_APP_VERSION, paramList, AppVersionInfo.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJson(HttpType.GET, requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<AreaInfo> getAreaIdByAddress(UserSession userSession, String country, String province, String city, String district) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("userId", "" + userSession.getUserId()));
        paramList.add(new Parameter("session", userSession.getSession()));
        paramList.add(new Parameter("country", country));
        paramList.add(new Parameter("province", province));
        paramList.add(new Parameter("city", city));
        paramList.add(new Parameter("district", district));
        ApiHttpRequest<AreaInfo> requestObject = new ApiHttpRequest<>(UrlConstant.GET_AREA_ID_BY_ADDRESS, paramList, AreaInfo.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJson(HttpType.GET, requestObject, defaultErrorInfo);
    }

    /**
     *******************************************************************************************************************
     *<-----------------------------------------以下为Post方式提交信息的业务接口--------------------------------------->
     ********************************************************************************************************************
     */

    @Override
    public ApiResponse<Void> postPhoneToRegisterVerify(String mobilePhone) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("mobilePhone", mobilePhone));
        ApiHttpRequest<Void> requestObject = new ApiHttpRequest<>(UrlConstant.POST_PHONE_TO_REGISTER_VERIFY, paramList, Void.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJson(HttpType.POST, requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<UserSession> postUserRegister(String userName, String userPassword, String userPhone, String verifyCode) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("userName", userName));
        paramList.add(new Parameter("userPassword", userPassword));
        paramList.add(new Parameter("userPhone", userPhone));
        paramList.add(new Parameter("verifyCode", verifyCode));
        ApiHttpRequest<UserSession> requestObject = new ApiHttpRequest<>(UrlConstant.POST_USER_REGISTER, paramList, UserSession.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJson(HttpType.POST, requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<UserSession> postUserLogin(String userAccount, String userPassword) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("userAccount", userAccount));
        paramList.add(new Parameter("userPassword", userPassword));
        ApiHttpRequest<UserSession> requestObject = new ApiHttpRequest<>(UrlConstant.POST_USER_LOGIN, paramList, UserSession.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJson(HttpType.POST, requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<Void> postPhoneToModifyPassword(ModifyPwdType typeTag, String userPhone) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("typeTag", "" + typeTag.getType()));
        paramList.add(new Parameter("userPhone", userPhone));
        ApiHttpRequest<Void> requestObject = new ApiHttpRequest<>(UrlConstant.POST_PHONE_TO_MODIFY_PASSWORD, paramList, Void.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJson(HttpType.POST, requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<UserToken> postVerifyCodeToModifyPassword(ModifyPwdType typeTag, String userPhone, String verifyCode) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("typeTag", "" + typeTag.getType()));
        paramList.add(new Parameter("userPhone", userPhone));
        paramList.add(new Parameter("verifyCode", verifyCode));
        ApiHttpRequest<UserToken> requestObject = new ApiHttpRequest<>(UrlConstant.POST_VERIFYCODE_TO_MODIFY_PASSWORD, paramList, UserToken.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJson(HttpType.POST, requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<Void> postNewPasswordToModifyLoginPassword(int userId, String userPassword, String token) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("userId", "" + userId));
        paramList.add(new Parameter("userPassword", userPassword));
        paramList.add(new Parameter("token", token));
        ApiHttpRequest<Void> requestObject = new ApiHttpRequest<>(UrlConstant.POST_NEW_PASSWORD_TO_MODIFY_LOGIN_PASSWORD, paramList, Void.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJson(HttpType.POST, requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<ResponsedDevice> postBindDevice(UserSession userSession, String deviceMac) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("userId", "" + userSession.getUserId()));
        paramList.add(new Parameter("session", userSession.getSession()));
        paramList.add(new Parameter("deviceMac", deviceMac));
        ApiHttpRequest<ResponsedDevice> requestObject = new ApiHttpRequest<>(UrlConstant.POST_BIND_DEVICE, paramList, ResponsedDevice.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJson(HttpType.POST, requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<Void> postUnbindDevice(UserSession userSession, int deviceId) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("userId", "" + userSession.getUserId()));
        paramList.add(new Parameter("session", userSession.getSession()));
        paramList.add(new Parameter("deviceId", "" + deviceId));
        ApiHttpRequest<Void> requestObject = new ApiHttpRequest<>(UrlConstant.POST_UNBIND_DEVICE, paramList, Void.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJson(HttpType.POST, requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<Void> postAddWifi(UserSession userSession, String wifiSSID, String wifiPassword, String wifiMac,
                                         double wifiLongitude, double wifiLatitude, int wifiAreaId, String wifiAddress) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("userId", "" + userSession.getUserId()));
        paramList.add(new Parameter("session", userSession.getSession()));
        paramList.add(new Parameter("wifiSSID", wifiSSID));
        paramList.add(new Parameter("wifiPassword", wifiPassword));
        paramList.add(new Parameter("wifiMac", wifiMac));
        paramList.add(new Parameter("wifiLongitude", "" + wifiLongitude));
        paramList.add(new Parameter("wifiLatitude", "" + wifiLatitude));
        paramList.add(new Parameter("wifiAreaId", "" + wifiAreaId));
        paramList.add(new Parameter("wifiAddress", wifiAddress));
        ApiHttpRequest<Void> requestObject = new ApiHttpRequest<>(UrlConstant.POST_ADD_WIFI, paramList, Void.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJson(HttpType.POST, requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<Void> postDeleteWifi(UserSession userSession, int wifiId) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("userId", "" + userSession.getUserId()));
        paramList.add(new Parameter("session", userSession.getSession()));
        paramList.add(new Parameter("wifiId", "" + wifiId));
        ApiHttpRequest<Void> requestObject = new ApiHttpRequest<>(UrlConstant.POST_DELETE_WIFI, paramList, Void.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJson(HttpType.POST, requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<Void> postUpdateWifi(UserSession userSession, int wifiId, String wifiSSID, String wifiPassword,
                                            double wifiLongitude, double wifiLatitude, int wifiAreaId, String wifiAddress) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("userId", "" + userSession.getUserId()));
        paramList.add(new Parameter("session", userSession.getSession()));
        paramList.add(new Parameter("wifiId", "" + wifiId));
        paramList.add(new Parameter("wifiSSID", wifiSSID));
        paramList.add(new Parameter("wifiPassword", wifiPassword));
        paramList.add(new Parameter("wifiLongitude", "" + wifiLongitude));
        paramList.add(new Parameter("wifiLatitude", "" + wifiLatitude));
        paramList.add(new Parameter("wifiAreaId", "" + wifiAreaId));
        paramList.add(new Parameter("wifiAddress", wifiAddress));
        ApiHttpRequest<Void> requestObject = new ApiHttpRequest<>(UrlConstant.POST_UPDATE_WIFI, paramList, Void.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJson(HttpType.POST, requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<Void> postNewPasswordToModifyPayPassword(int userId, String userPassword, String token) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("userId", "" + userId));
        paramList.add(new Parameter("userPassword", userPassword));
        paramList.add(new Parameter("token", token));
        ApiHttpRequest<Void> requestObject = new ApiHttpRequest<>(UrlConstant.POST_NEW_PASSWORD_TO_MODIFY_PAY_PASSWORD, paramList, Void.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJson(HttpType.POST, requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<Void> postBuyPackage(UserSession userSession, int packageType, int count, float totalPrice) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("userId", "" + userSession.getUserId()));
        paramList.add(new Parameter("session", userSession.getSession()));
        paramList.add(new Parameter("packageType", "" + packageType));
        paramList.add(new Parameter("count", "" + count));
        paramList.add(new Parameter("totalPrice", "" + totalPrice));
        ApiHttpRequest<Void> requestObject = new ApiHttpRequest<>(UrlConstant.POST_BUY_PACKAGE, paramList, Void.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJson(HttpType.POST, requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<BankType> postBindBankCardForBankType(UserSession userSession, String accountNum) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("userId", "" + userSession.getUserId()));
        paramList.add(new Parameter("session", userSession.getSession()));
        paramList.add(new Parameter("accountNum", accountNum));
        ApiHttpRequest<BankType> requestObject = new ApiHttpRequest<>(UrlConstant.POST_BIND_BANKCARD_FOR_BANK_TYPE, paramList, BankType.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJson(HttpType.POST, requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<Void> postBindBankCardToVerifyIdentity(UserSession userSession, String cardholderName, String cardholderPhone, String accountNum, int bankType) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("userId", "" + userSession.getUserId()));
        paramList.add(new Parameter("session", userSession.getSession()));
        paramList.add(new Parameter("cardholderName", cardholderName));
        paramList.add(new Parameter("cardholderPhone", cardholderPhone));
        paramList.add(new Parameter("accountNum", accountNum));
        paramList.add(new Parameter("bankType", "" + bankType));
        ApiHttpRequest<Void> requestObject = new ApiHttpRequest<>(UrlConstant.POST_BIND_BANKCARD_TO_VERIFY_IDENTITY, paramList, Void.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJson(HttpType.POST, requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<ResponsedToken> postBindBankCardForVerifyCode(UserSession userSession, String cardholderPhone, String accountNum) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("userId", "" + userSession.getUserId()));
        paramList.add(new Parameter("session", userSession.getSession()));
        paramList.add(new Parameter("cardholderPhone", cardholderPhone));
        paramList.add(new Parameter("accountNum", accountNum));
        ApiHttpRequest<ResponsedToken> requestObject = new ApiHttpRequest<>(UrlConstant.POST_BIND_BANKCARD_FOR_VERIFYCODE, paramList, ResponsedToken.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJson(HttpType.POST, requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<Void> postBindBankCardWithVerifyCode(UserSession userSession, String cardholderPhone, String accountNum, String token) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("userId", "" + userSession.getUserId()));
        paramList.add(new Parameter("session", userSession.getSession()));
        paramList.add(new Parameter("cardholderPhone", cardholderPhone));
        paramList.add(new Parameter("accountNum", accountNum));
        paramList.add(new Parameter("token", token));
        ApiHttpRequest<Void> requestObject = new ApiHttpRequest<>(UrlConstant.POST_BIND_BANKCARD_WITH_VERIFYCODE, paramList, Void.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJson(HttpType.POST, requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<ResponsedToken> postUnbindBankCardForVerify(UserSession userSession, String payPassword) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("userId", "" + userSession.getUserId()));
        paramList.add(new Parameter("session", userSession.getSession()));
        paramList.add(new Parameter("payPassword", payPassword));
        ApiHttpRequest<ResponsedToken> requestObject = new ApiHttpRequest<>(UrlConstant.POST_UNBIND_BANKCARD_FOR_VERIFY, paramList, ResponsedToken.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJson(HttpType.POST, requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<Void> postUnbindBankCard(UserSession userSession, String accountNum, String token) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("userId", "" + userSession.getUserId()));
        paramList.add(new Parameter("session", userSession.getSession()));
        paramList.add(new Parameter("accountNum", accountNum));
        paramList.add(new Parameter("token", token));
        ApiHttpRequest<Void> requestObject = new ApiHttpRequest<>(UrlConstant.POST_UNBIND_BANKCARD, paramList, Void.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJson(HttpType.POST, requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<Void> postSetDefaultBankCard(UserSession userSession, String accountNum) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("userId", "" + userSession.getUserId()));
        paramList.add(new Parameter("session", userSession.getSession()));
        paramList.add(new Parameter("accountNum", accountNum));
        ApiHttpRequest<Void> requestObject = new ApiHttpRequest<>(UrlConstant.POST_SET_DEFAULT_BANKCARD, paramList, Void.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJson(HttpType.POST, requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<Void> postOutMoney(UserSession userSession, String accountNum, float outMoney) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("userId", "" + userSession.getUserId()));
        paramList.add(new Parameter("session", userSession.getSession()));
        paramList.add(new Parameter("accountNum", accountNum));
        paramList.add(new Parameter("outMoney", "" + outMoney));
        ApiHttpRequest<Void> requestObject = new ApiHttpRequest<>(UrlConstant.POST_OUT_MONEY, paramList, Void.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJson(HttpType.POST, requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<Void> postModifyUserName(UserSession userSession, String userName) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("userId", "" + userSession.getUserId()));
        paramList.add(new Parameter("session", userSession.getSession()));
        paramList.add(new Parameter("userName", userName));
        ApiHttpRequest<Void> requestObject = new ApiHttpRequest<>(UrlConstant.POST_MODIFY_USERNAME, paramList, Void.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJson(HttpType.POST, requestObject, defaultErrorInfo);
    }

    @Override
    public ApiResponse<Void> postUserFeedback(UserSession userSession, int appPlatform, int appVersionCode, String feedbackContent, long time) {
        List<Parameter> paramList = new ArrayList<>();
        paramList.add(new Parameter("userId", "" + userSession.getUserId()));
        paramList.add(new Parameter("session", userSession.getSession()));
        paramList.add(new Parameter("appPlatform", "" + appPlatform));
        paramList.add(new Parameter("appVersionCode", "" + appVersionCode));
        paramList.add(new Parameter("feedbackContent", feedbackContent));
        paramList.add(new Parameter("time", "" + time));
        ApiHttpRequest<Void> requestObject = new ApiHttpRequest<>(UrlConstant.POST_USER_FEEDBACK, paramList, Void.class);
        ErrorInfo defaultErrorInfo = new ErrorInfo(ErrorSets.CODE_NETWORK_REQUEST_FAILED, ErrorSets.MSG_NETWORK_REQUEST_FAILED);
        return ApiJsonParseHelper.requestAndParseJson(HttpType.POST, requestObject, defaultErrorInfo);
    }

}
